# -*- coding: utf-8 -*-

"""
@Datetime: 2019/1/1
@Author: Zhang Yafei
"""
import sys
import www
import os
import traceback
from application import app, manager, db
from Kingadmin import admin_setup
from flask_script import Server
from flask_migrate import Migrate, MigrateCommand
from admin import *

os.environ['ops_config'] = 'local'

manager.add_command('runserver', Server(host='0.0.0.0', port=app.config['SERVER_PORT'], use_debugger=True, use_reloader=True))

admin_setup.admin_auto_discover()

Migrate(app, db)

"""
# 数据库迁移命令
    python manage.py db init
    python manage.py db migrate
    python manage.py db upgrade
"""
manager.add_command('db', MigrateCommand)


def main():
    manager.run()


if __name__ == '__main__':
    try:
        sys.exit(main())
    except Exception as e:
        traceback.print_exc()